<template>
  <div>
    <el-button :type="carsListBtnId == item.id ? 'danger':''" size="small" v-for="item in carsListBtn" :key="item.id" @click="getTypeList(item)" >{{item.value}}</el-button>
  </div>
</template>

<script>
import { getCarsAttrs, getCarsTypeAttrs } from "@/api/carsAttr.js"

export default {
  data() {
    return {
      carsListBtn: [],
      dataId: "",
      carsListBtnId: "",
    }
  },
  mounted() {
    this.getCarsAttrsFun();
  },
  methods: {
    getCarsAttrsFun() {
      getCarsAttrs()
        .then((res) => {
          this.carsListBtn = res.data.data;
        })
    },
    getTypeList(item) {
      this.carsListBtnId = item.id;
      this.currentItemData = item;
      getCarsTypeAttrs({typeId: item.id})
        .then((res) => {
          this.$emit("getAttrList",{
            attr_basic_data: item, // 公用属性
            attr_data: res.data.data
          });
        })
    }
  }
}
</script>

<style lang="less" scoped>

</style>